using XNgine.DebugConsole;
using XNgine.DebugConsole.Commands;
using XNgine.Misc;

namespace XNgine.ConsoleComponent.Commands
{
    public static class CommandRegister
    {
        private static readonly NamedItemCollection<Command> commands = new NamedItemCollection<Command>();

        public static void Register(Command command)
        {
            commands.Add(command);
        }

        public static Command Handler(string command)
        {
            Command result = commands[command];
            if (result == null)
                throw new CommandNotRegisteredException(command);
            return result;
        }
    }
}